/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ssp.utility;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Map;

/**
 * マップのvalue値の降順に並べるComparator
 * @author yamazaki
 */
public final class MapValueDescending implements Comparator, Serializable {
    
    private static final long serialVersionUID = 266280447170989652L;
    
    private Map map;
    
    public MapValueDescending(Map map) {
        this.map = map;
    }

    @Override
    public int compare(Object o1, Object o2) {
        double val1 = ((Double)map.get(o1)).doubleValue();
        double val2 = ((Double)map.get(o2)).doubleValue();
        if(val2 > val1) {
            return 1;
        } else {
            return -1;
        }
    }
    
}
